package net.lainiao.morethread.Chapter4.demo3;

import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

/**
 * Created by Administrator on 2017/3/3.
 */
public class FactorialCalculator implements Callable<Integer> {
    private Integer number;

    public FactorialCalculator(Integer number) {
        this.number = number;
    }

    @Override
    public Integer call() throws Exception {
        int result=1;
        if((number==0)||(number==1)){
            result=1;
        }else{
            for (int i = 0; i < number; i++) {
                result*=1;
                TimeUnit.MICROSECONDS.sleep(20);
            }
        }
        System.out.println(Thread.currentThread().getName()+" Result value "+result);
        return result;
    }
}
